<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class Linksrecordexport extends Model
{
    protected $table = 'links_record_export';
    protected $primaryKey = 'id';

    public static function getLinkRecordReportCount($links_id,$batch)
    {
        return self::where("links_id",$links_id)->where("batch",$batch)->orderBy("id","DESC")->count();
    }

    public static function insertLinkRecordReport($links_id,$batch,$time_start,$time_end,$exe_count)
    {
        return self::insert(["links_id"=>$links_id,"batch"=>$batch,"time_start"=>$time_start,"time_end"=>$time_end,"exe_count"=>$exe_count,"created_at"=>time()]);
    }

    public static function updateLinkRecordReport($links_id,$batch,$exe_count,$status)
    {
        return self::where("links_id",$links_id)->where("batch",$batch)->update(["exe_count"=>$exe_count,"status"=>$status]);
    }
}
